/**
* Copyright (c) 2015 UNI-TREND Co., Ltd.
* All rights reserved.  
*  
* @file        log.h
* @brief       record sth when running
* @version     1.0 
* @author      
* @Email       
* @date        2015-11-13
*/
#pragma once
#include <string>
#include "Assistant.h"

using namespace std;
/**
*   @brief: CLog for UTD is the basic output and recorder for the process of scope running issues
*   @author:
*   @note: create on 2015-11-13
*   @note: 
*/
class CLog
{
private:
    CLog(){};
    ~CLog(){};
    
public:
    /** enum of types for details of logging */
    typedef enum
    {
        LOG_LESS_10BYTE = 0,
        LOG_2END,
        LOG_FILE_LINE,
        LOG_FILE_LINE_TIME,
        LOG_TIK_TOK,
        
        LOG_FULL
    } LOG_DETAILED;
    /** static func, directly call, should be polymorphic
            *   @brief: warning lvl
            *   only support output to 1 location. TODO: create files/mems to record. no STATIC func.
            */            
    static BOOL error(string warn, LOG_DETAILED type = LOG_LESS_10BYTE);
    static BOOL warning(string warn, LOG_DETAILED type = LOG_LESS_10BYTE);
    static BOOL info(string warn, LOG_DETAILED type = LOG_LESS_10BYTE);
private:
    /** real work to record in ram or file*/
    static BOOL record(string str);

    static const int MAX_LOG_LENGTH;

    static char* m_logger;
    static int m_logBeginFrom;
    static int m_logLength;
};

// TODO: always simple output on 2000, because little ram(1k log buff)

/** simply error output to CLog::m_logger */
#define ERROR(_str) CLog::error(_str)
/** simply warning output to CLog::m_logger */
#define WARNING(_str) CLog::warning(_str)
/** simply info output to CLog::m_logger */
#define INFO(_str) CLog::info(_str)
/** TIKTOK output to CLog::m_logger 
* @note: record time for running
*/
#ifdef OPEN_TIK_TOK
#define TIK_TOK(_str) CLog::info(_str, CLog::LOG_TIK_TOK)
#else
#define TIK_TOK(_str) ;
#endif
